#include "Meeting.h"


Meeting::Meeting(void):subject("default"){
	this->setTimeStart(0);
	this->setTimeEnd(0);
}

Meeting::~Meeting(void){
	//delete &(this->subject);
}

Meeting::Meeting(float start, float end, const string& subject):timeStart(0),timeEnd(0),subject(subject){
	if (start <= end){
		this->setTimeStart(start);
		this->setTimeEnd(end);
	}
}

Meeting::Meeting(const Meeting &meeting):subject(meeting.getSubject()){
		//this->setSubject();
		this->setTimeStart(meeting.getTimeStart());
		this->setTimeEnd(meeting.getTimeEnd());
}

const Meeting & Meeting::operator =(const Meeting &meeting){
	if (&meeting != this){

		this->setSubject(meeting.getSubject());
		this->setTimeStart(meeting.getTimeStart());
		this->setTimeEnd(meeting.getTimeEnd());
	}
	return *this;
}

bool Meeting::compare(const Meeting & meeting) const {
	if ((meeting.getSubject() == this->getSubject())
		&& (meeting.getTimeStart() == this->getTimeStart())
		&& (meeting.getTimeEnd() == this->getTimeEnd())){
			return true;
	}

	return false;
}

void Meeting::setTimeStart(float time){

	if (time >= 0 && time < 24)
		this->timeStart = time;
}

void Meeting::setTimeEnd(float time){
	if (time >= 0 && time < 24)
		this->timeEnd = time;
}

void Meeting::setSubject(const string &sub){
	delete &(this->subject);
	this->subject = sub;
}

float Meeting::getTimeStart() const{
	return this->timeStart;
}
	
float Meeting::getTimeEnd() const{
	return this->timeEnd;
}
	
const string& Meeting::getSubject() const{
	return this->subject;
}

Type_Code Meeting::whoAmI() const{
	return BASE;
}


//true if ther is time overlap
bool Meeting::checkColission(const Meeting& m) const {
	if ( (m.getTimeStart() < this->getTimeEnd()) && (m.getTimeEnd() > this->getTimeStart() ) )
		return true;
	else
		return false;
}


ostream & Meeting::toString(ostream & os) const{
	os << this->getTimeStart() << ", " << this->getTimeEnd() << ", " << this->getSubject() << endl;
	return os;
}